<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<!-- Meta, title, CSS, favicons, etc. -->
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">

<title>随便打TCS系统</title>

<!-- Bootstrap -->
<link href="<%=basePath%>vendors/bootstrap/dist/css/bootstrap.min.css"
	rel="stylesheet">
<!-- Font Awesome -->
<link
	href="//netdna.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css"
	rel="stylesheet">
<!-- NProgress -->
<link href="<%=basePath%>vendors/nprogress/nprogress.css"
	rel="stylesheet">
<!-- iCheck -->
<link href="<%=basePath%>vendors/iCheck/skins/flat/green.css"
	rel="stylesheet">

<!-- bootstrap-progressbar -->
<link
	href="<%=basePath%>vendors/bootstrap-progressbar/css/bootstrap-progressbar-3.3.4.min.css"
	rel="stylesheet">
<!-- JQVMap -->
<link href="<%=basePath%>vendors/jqvmap/dist/jqvmap.min.css"
	rel="stylesheet" />
<!-- bootstrap-daterangepicker -->
<link
	href="<%=basePath%>vendors/bootstrap-daterangepicker/daterangepicker.css"
	rel="stylesheet">

<!-- Custom Theme Style -->
<link href="<%=basePath%>build/css/custom.min.css" rel="stylesheet">

</head>
<body class="nav-md">
	<%@ include file="loginCheck.jsp"%>
	<div class="container body">
		<div class="main_container">
			<div class="col-md-3 left_col">
				<div class="left_col scroll-view">
					<div class="clearfix"></div>
					<br />
				</div>
			</div>
			<!-- page content -->
			<div class="right_col" role="main">
				<div class="">
					<div class="clearfix"></div>
					<div class="row">
						<div class="col-md-12 col-sm-12 col-xs-12">
							<div class="x_panel">
								<div class="x_content">
									<span class="section">分销配置</span>
									<form name="myForm" class="form-horizontal form-label-left"
										novalidate method="post" enctype="multipart/form-data"
										id="myForm">
										<div class="item form-group" style="display: none">
											<label class="control-label col-md-3 col-sm-3 col-xs-12"
												for="name">id<span class="required"></span>
											</label>
											<div class="col-md-6 col-sm-6 col-xs-12">
												<input id="id" name="id"
													class="form-control col-md-7 col-xs-12" type="text"
													value="${users.id}">
											</div>
										</div>
										<div class="form-group" id="personal" <c:if test="${isLTH == 1}">style="display:none;"</c:if>>
											<label class="control-label col-md-3 col-sm-3 col-xs-12"
												for="name">分享者赠送通话金额 <span class="required">*</span>
											</label>
											<div class="col-md-6 col-sm-6 col-xs-12">
												<input id="callmeshare" name="callmeshare"
													class="form-control col-md-7 col-xs-12" type="text"
													placeholder="例如：10" value="${users.callmeshare}">
											</div>
											<span id="callmeshareprompt"
												style="font-size: 14px; color: #ff0033; display: none">
												如不允许分享者赠送通话,请设置为0</span>
										</div>
										<div class="form-group" id="personal" <c:if test="${isLTH == 1}">style="display:none;"</c:if>>
											<label class="control-label col-md-3 col-sm-3 col-xs-12"
												for="name">上级分享者赠送通话金额 <span class="required">*</span>
											</label>
											<div class="col-md-6 col-sm-6 col-xs-12">
												<input id="callshareper" name="callshareper"
													class="form-control col-md-7 col-xs-12" type="text"
													placeholder="例如：10" value="${users.callshareper}">
											</div>
											<span id="callshareperprompt"
												style="font-size: 14px; color: #ff0033; display: none">
												如不允许上级分享者赠送通话,请设置为0</span>
										</div>
										<div class="form-group" id="personal" <c:if test="${isLTH == 1}">style="display:none;"</c:if>>
											<label class="control-label col-md-3 col-sm-3 col-xs-12"
												for="name">被分享者赠送通话金额 <span class="required">*</span>
											</label>
											<div class="col-md-6 col-sm-6 col-xs-12">
												<input id="callparshare" name="callparshare"
													class="form-control col-md-7 col-xs-12" type="text"
													placeholder="例如：10" value="${users.callparshare}">
											</div>
											<span id="callparshareprompt"
												style="font-size: 14px; color: #ff0033; display: none">
												如不允许被分享者赠送通话,请设置为0</span>
										</div>
										<div class="form-group" id="personal">
											<label class="control-label col-md-3 col-sm-3 col-xs-12"
												for="name">分享者赠送购物金额 <span class="required">*</span>
											</label>
											<div class="col-md-6 col-sm-6 col-xs-12">
												<input id="shopmeshare" name="shopmeshare"
													class="form-control col-md-7 col-xs-12" type="text"
													placeholder="例如：10" value="${users.shopmeshare}">
											</div>
											<span id="shopmeshareprompt"
												style="font-size: 14px; color: #ff0033; display: none">
												如不允许分享者赠送购物券,请设置为0</span>
										</div>
										<div class="form-group" id="personal">
											<label class="control-label col-md-3 col-sm-3 col-xs-12"
												for="name">上级分享者赠送购物金额 <span class="required">*</span>
											</label>
											<div class="col-md-6 col-sm-6 col-xs-12">
												<input id="shopshareper" name="shopshareper"
													class="form-control col-md-7 col-xs-12" type="text"
													placeholder="例如：10" value="${users.shopshareper}">
											</div>
											<span id="shopshareperprompt"
												style="font-size: 14px; color: #ff0033; display: none">
												如不允许上级分享者赠送购物券,请设置为0</span>
										</div>
										<div class="form-group" id="personal">
											<label class="control-label col-md-3 col-sm-3 col-xs-12"
												for="name">被分享者赠送购物金额 <span class="required">*</span>
											</label>
											<div class="col-md-6 col-sm-6 col-xs-12">
												<input id="shopparshare" name="shopparshare"
													class="form-control col-md-7 col-xs-12" type="text"
													placeholder="例如：10" value="${users.shopparshare}">
											</div>
											<span id="shopparshareprompt"
												style="font-size: 14px; color: #ff0033; display: none">
												如不允许被分享者赠送购物券,请设置为0</span>
										</div>
										<div class="item form-group">
											<label class="control-label col-md-3 col-sm-3 col-xs-12"
												for="name">在线充值一级分润比例 <span class="required">*</span>
											</label>
											<div class="col-md-6 col-sm-6 col-xs-12">
												<input id="reratio1" class="form-control col-md-7 col-xs-12"
													data-validate-length-range="6" data-validate-words="2"
													name="reratio1" placeholder="例如：0.05（0.05等于5%）"
													required="required" type="text" value="${users.reratio1}">
											</div>
											<c:if test="${users.id == 'd093179851af43dfbb1bc6639334b109'}">
												<a href="javascript:" type="submit"
												   class="btn btn-success"
												   onclick="toRebate('1');">一级(一店)比例</a>
											</c:if>
										</div>
										<div class="item form-group">
											<label class="control-label col-md-3 col-sm-3 col-xs-12"
												for="name">在线充值二级分润比例 <span class="required">*</span>
											</label>
											<div class="col-md-6 col-sm-6 col-xs-12">
												<input id="reratio2" class="form-control col-md-7 col-xs-12"
													data-validate-length-range="6" data-validate-words="2"
													name="reratio2" placeholder="例如：0.05（0.05等于5%）"
													required="required" type="text" value="${users.reratio2}">
											</div>
											<c:if test="${users.id == 'd093179851af43dfbb1bc6639334b109'}">
												<a href="javascript:" type="submit"
												   class="btn btn-success"
												   onclick="toRebate('2');">二级(二店)比例</a>
											</c:if>
										</div>
										<div class="item form-group">
											<label class="control-label col-md-3 col-sm-3 col-xs-12"
												for="name">在线充值三级分润比例 <span class="required">*</span>
											</label>
											<div class="col-md-6 col-sm-6 col-xs-12">
												<input id="reratio3" class="form-control col-md-7 col-xs-12"
													data-validate-length-range="6" data-validate-words="2"
													name="reratio3" placeholder="例如：0.05（0.05等于5%）"
													required="required" type="text" value="${users.reratio3}">
											</div>
											<c:if test="${users.id == 'd093179851af43dfbb1bc6639334b109'}">
												<a href="javascript:" type="submit"
												   class="btn btn-success"
												   onclick="toRebate('3');">三级(三店)比例</a>
											</c:if>
										</div>
                                        <c:if test="${users.id == 'd093179851af43dfbb1bc6639334b109'}">
                                        <div class="item form-group">
                                            <label class="control-label col-md-3 col-sm-3 col-xs-12"
                                                   for="name">自建商城返佣比例 <span class="required">*</span>
                                            </label>
                                            <div class="col-md-6 col-sm-6 col-xs-12">
                                                <input id="selfshopratio" class="form-control col-md-7 col-xs-12"
                                                       data-validate-length-range="6" data-validate-words="2"
                                                       name="selfshopratio" placeholder="例如：0.9"
                                                       required="required" type="text" value="${users.selfshopratio}">
                                            </div>
                                        </div>
                                        </c:if>
										<c:if test="${users.ismember == 1}">
										<div class="item form-group">
											<label class="control-label col-md-3 col-sm-3 col-xs-12"
												   for="name">基本会员名 <span class="required">*</span>
											</label>
											<div class="col-md-6 col-sm-6 col-xs-12">
												<input id="firstclass" class="form-control col-md-7 col-xs-12"
													   data-validate-length-range="6" data-validate-words="2"
													   name="firstclass" placeholder="例如：基本会员"
													   required="required" type="text" value="${users.firstclass}">
											</div>
										</div>
										<div class="form-group">
											<label class="control-label col-md-3 col-sm-3 col-xs-12">基本会员规则
												<span class="required">*</span>
											</label>
											<div class="col-md-6 col-sm-6 col-xs-12">
											<textarea name="firstrule" id="firstrule" class="form-control"><c:if
													test="${users.firstrule==null || users.firstrule==''}">&lt;p&gt;例如：今日任务请看具体描述&lt;/p&gt;</c:if>${users.firstrule}</textarea>
											</div>
										<span id="fRule"
											  style="font-size: 14px; color: #ff0033; display: none">
											自动清除所有空格，内容开始或分段请使用&lt;p&gt;内容&lt;/p&gt;，例如：&lt;p&gt;段落1&lt;/p&gt;&lt;p&gt;段落2&lt;/p&gt;</span>
								        </div>
										</c:if>
										<div class="item form-group">
											<label class="control-label col-md-3 col-sm-3 col-xs-12"
												   for="name">淘宝客用户分润比例 <span class="required">*</span>
											</label>
											<div class="col-md-6 col-sm-6 col-xs-12">
												<input id="rebateratio" class="form-control col-md-7 col-xs-12"
													   data-validate-length-range="6" data-validate-words="2"
													   name="rebateratio" placeholder="例如：0.85（注：提现费用需0.1，建议最高设置0.9）"
													   required="required" type="text" value="${users.rebateratio}">
											</div>
										</div>
										<div class="item form-group">
											<label class="control-label col-md-3 col-sm-3 col-xs-12"
												   for="name">淘宝客二级用户分润比例 <span class="required">*</span>
											</label>
											<div class="col-md-6 col-sm-6 col-xs-12">
												<input id="rebateratio2" class="form-control col-md-7 col-xs-12"
													   data-validate-length-range="6" data-validate-words="2"
													   name="rebateratio2" placeholder="例如：0.9（注：此分润为佣金*0.9*0.9）"
													   required="required" type="text" value="${users.rebateratio2}">
											</div>
										</div>
										<c:if test="${users.id == '23be3fe6cb954281b89da2f6e6ff684f'}">
										<div class="item form-group">
											<label class="control-label col-md-3 col-sm-3 col-xs-12"
												   for="name">淘宝客三级用户分润比例 <span class="required">*</span>
											</label>
											<div class="col-md-6 col-sm-6 col-xs-12">
												<input id="rebateratio3" class="form-control col-md-7 col-xs-12"
													   data-validate-length-range="6" data-validate-words="2"
													   name="rebateratio3" placeholder="例如：0.9（注：此分润为佣金*0.9*0.9*0.9）"
													   required="required" type="text" value="${users.rebateratio2}">
											</div>
										</div>
										</c:if>
										<c:if test="${users.ismember == 1}">
										<div class="item form-group">
											<label class="control-label col-md-3 col-sm-3 col-xs-12"
												   for="name">自定义会员名 <span class="required">*</span>
											</label>
											<div class="col-md-6 col-sm-6 col-xs-12">
												<input id="secondclass" class="form-control col-md-7 col-xs-12"
													   data-validate-length-range="6" data-validate-words="2"
													   name="secondclass" placeholder="例如：升级会员"
													   required="required" type="text" value="${users.secondclass}">
											</div>
										</div>
										<div class="form-group">
											<label class="control-label col-md-3 col-sm-3 col-xs-12">自定义会员规则
												<span class="required">*</span>
											</label>
											<div class="col-md-6 col-sm-6 col-xs-12">
											<textarea name="secondrule" id="secondrule" class="form-control"><c:if
													test="${users.secondrule==null || users.secondrule==''}">&lt;p&gt;例如：今日任务请看具体描述&lt;/p&gt;</c:if>${users.secondrule}</textarea>
											</div>
											<span id="sRule"
												  style="font-size: 14px; color: #ff0033; display: none">
											自动清除所有空格，内容开始或分段请使用&lt;p&gt;内容&lt;/p&gt;，例如：&lt;p&gt;段落1&lt;/p&gt;&lt;p&gt;段落2&lt;/p&gt;</span>
										</div>
										<div class="item form-group">
											<label class="control-label col-md-3 col-sm-3 col-xs-12"
												   for="name">升级所属人数 <span class="required">*</span>
											</label>
											<div class="col-md-6 col-sm-6 col-xs-12">
												<input id="upgrade2" class="form-control col-md-7 col-xs-12"
													   data-validate-length-range="6" data-validate-words="2"
													   name="upgrade2" placeholder="例如：1000"
													   required="required" type="text" value="${users.upgrade2}">
											</div>
										</div>
										<div class="item form-group">
											<label class="control-label col-md-3 col-sm-3 col-xs-12"
												   for="name">淘宝客用户分润比例 <span class="required">*</span>
											</label>
											<div class="col-md-6 col-sm-6 col-xs-12">
												<input id="rebate2ratio" class="form-control col-md-7 col-xs-12"
													   data-validate-length-range="6" data-validate-words="2"
													   name="rebate2ratio" placeholder="例如：0.85（注：提现费用需0.1，建议最高设置0.9）"
													   required="required" type="text" value="${users.rebate2ratio}">
											</div>
										</div>
										<div class="item form-group">
											<label class="control-label col-md-3 col-sm-3 col-xs-12"
												   for="name">淘宝客二级用户分润比例 <span class="required">*</span>
											</label>
											<div class="col-md-6 col-sm-6 col-xs-12">
												<input id="rebate2ratio2" class="form-control col-md-7 col-xs-12"
													   data-validate-length-range="6" data-validate-words="2"
													   name="rebate2ratio2" placeholder="例如：0.9（注：此分润为佣金*0.9*0.9）"
													   required="required" type="text" value="${users.rebate2ratio2}">
											</div>
										</div>
										<div class="item form-group">
											<label class="control-label col-md-3 col-sm-3 col-xs-12"
												   for="name">团队收益分润比例 <span class="required">*</span>
											</label>
											<div class="col-md-6 col-sm-6 col-xs-12">
												<input id="group2ratio" class="form-control col-md-7 col-xs-12"
													   data-validate-length-range="6" data-validate-words="2"
													   name="group2ratio" placeholder="例如：0.9（注：此分润为佣金*0.9*0.9）"
													   required="required" type="text" value="${users.group2ratio}">
											</div>
										</div>
										<div class="form-group">
											<label class="control-label col-md-3 col-sm-3 col-xs-12">超级会员规则
												<span class="required">*</span>
											</label>
											<div class="col-md-6 col-sm-6 col-xs-12">
											<textarea name="superrule" id="superrule" class="form-control"><c:if
												test="${users.superrule==null || users.superrule==''}">&lt;p&gt;例如：今日任务请看具体描述&lt;/p&gt;</c:if>${users.superrule}</textarea>
											</div>
											<span id="suRule"
												  style="font-size: 14px; color: #ff0033; display: none">
											自动清除所有空格，内容开始或分段请使用&lt;p&gt;内容&lt;/p&gt;，例如：&lt;p&gt;段落1&lt;/p&gt;&lt;p&gt;段落2&lt;/p&gt;</span>
										</div>
										<div class="item form-group">
											<label class="control-label col-md-3 col-sm-3 col-xs-12"
												   for="name">超级会员升级金额 <span class="required">*</span>
											</label>
											<div class="col-md-6 col-sm-6 col-xs-12">
												<input id="upsuper" class="form-control col-md-7 col-xs-12"
													   data-validate-length-range="6" data-validate-words="2"
													   name="upsuper" placeholder="例如：1000"
													   required="required" type="text" value="${users.upsuper}">
											</div>
										</div>
										<div class="item form-group">
											<label class="control-label col-md-3 col-sm-3 col-xs-12"
												   for="name">超级会员分润比例 <span class="required">*</span>
											</label>
											<div class="col-md-6 col-sm-6 col-xs-12">
												<input id="superratio" class="form-control col-md-7 col-xs-12"
													   data-validate-length-range="6" data-validate-words="2"
													   name="superratio" placeholder="例如：0.9（注：此分润为佣金*0.9）"
													   required="required" type="text" value="${users.superratio}">
											</div>
										</div>
										</c:if>
										<div class="item form-group">
											<label class="control-label col-md-3 col-sm-3 col-xs-12"
												   for="name">商家提现分润比例 <span class="required">*</span>
											</label>
											<div class="col-md-6 col-sm-6 col-xs-12">
												<input id="shopratio" class="form-control col-md-7 col-xs-12"
													   data-validate-length-range="6" data-validate-words="2"
													   name="shopratio" placeholder="例如：0.9"
													   required="required" type="text" value="${users.shopratio}">
											</div>
										</div>
										<div class="form-group">
											<div class="col-md-6 col-md-offset-3">
												<input id="revise" type="button" class="btn btn-success"
													value="确定">
											</div>
										</div>
									</form>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
			<!-- /page content -->
		</div>
	</div>
	<!-- /page content -->
	<!-- 上传图片并修改 -->
	<script src="<%=basePath%>vendors/jquery/dist/jquery.min.js"></script>
	<script>
		$("#firstrule").mouseover(function() {
			$("#fRule").css("display", "block");
		});
		$("#firstrule").mouseout(function() {
			$("#fRule").css("display", "none");
		});
		$("#secondclass").mouseover(function() {
			$("#sRule").css("display", "block");
		});
		$("#secondclass").mouseout(function() {
			$("#sRule").css("display", "none");
		});
		$("#secondclass").mouseover(function() {
			$("#suRule").css("display", "block");
		});
		$("#secondclass").mouseout(function() {
			$("#suRule").css("display", "none");
		});


		$("#callmeshare").mouseover(function() {
			$("#callmeshareprompt").css("display", "block");
		});
		$("#callmeshare").mouseout(function() {
			$("#callmeshareprompt").css("display", "none");
		});

		$("#callshareper").mouseover(function() {
			$("#callshareperprompt").css("display", "block");
		});
		$("#callshareper").mouseout(function() {
			$("#callshareperprompt").css("display", "none");
		});

		$("#callparshare").mouseover(function() {
			$("#callparshareprompt").css("display", "block");
		});
		$("#callparshare").mouseout(function() {
			$("#callparshareprompt").css("display", "none");
		});

		$("#shopmeshare").mouseover(function() {
			$("#shopmeshareprompt").css("display", "block");
		});
		$("#shopmeshare").mouseout(function() {
			$("#shopmeshareprompt").css("display", "none");
		});

		$("#shopshareper").mouseover(function() {
			$("#shopshareperprompt").css("display", "block");
		});
		$("#shopshareper").mouseout(function() {
			$("#shopshareperprompt").css("display", "none");
		});

		$("#shopparshare").mouseover(function() {
			$("#shopparshareprompt").css("display", "block");
		});
		$("#shopparshare").mouseout(function() {
			$("#shopparshareprompt").css("display", "none");
		});
	</script>
    <script type="text/javascript">
        function toRebate(type) {
            location.href = "usersrebate_index?type=" + type;
        }
    </script>
	<script type="text/javascript">
		$('#revise').click(function() {
			var partten1 = /^[0-9]{1,10}$/;
			var partten2 = /^[0-9]{1,18}\.[0-9]{1,2}$/;
			if ((!partten1.test($("#reratio1").val()) && !partten2.test($("#reratio1").val())) ||
					(!partten1.test($("#reratio2").val()) && !partten2.test($("#reratio2").val())) ||
					(!partten1.test($("#reratio3").val()) && !partten2.test($("#reratio3").val())) ||
					(!partten1.test($("#rebateratio").val()) && !partten2.test($("#rebateratio").val())) ||
					(!partten1.test($("#rebateratio2").val()) && !partten2.test($("#rebateratio2").val())) ||
                	(!partten1.test($("#shopratio").val()) && !partten2.test($("#shopratio").val())) ||
					(!partten1.test($("#callmeshare").val())) ||
					(!partten1.test($("#callparshare").val())) ||
					(!partten1.test($("#shopmeshare").val())) ||
					(!partten1.test($("#shopparshare").val())) ||
					(!partten1.test($("#callshareper").val())) ||
					(!partten1.test($("#shopshareper").val()))) {
				alert('请输入正确的数字，分享赠送金额只可填写整数，其他例如：10.00（整数最长为18位，小数最长为2位）');
				return false;
			}

			$.ajax({
				type : 'POST',
				url : 'allocations_do_update',
				data : $('#myForm').serialize(),
				dataType : 'json',
				success : function(date) {
					switch (date) {
					case -1:
						alert("登录超时，请重新登录");
						top.location.href = "login/${titleId}";
						break;
					case 1:
						alert("修改成功");
						location.href = "distribution_index";
						break;
					default:
						alert("修改失败，请重新操作");
						break;
					}
				},
				error : function() {
					alert("修改失败，请重新操作");
			    }
			});					
		});
	</script>
	<!-- Bootstrap -->
	<script src="<%=basePath%>vendors/bootstrap/dist/js/bootstrap.min.js"></script>
	<!-- FastClick -->
	<script src="<%=basePath%>vendors/fastclick/lib/fastclick.js"></script>
	<!-- NProgress -->
	<script src="<%=basePath%>vendors/nprogress/nprogress.js"></script>
	<!-- bootstrap-daterangepicker -->
	<script src="<%=basePath%>vendors/moment/min/moment.min.js"></script>
	<script
		src="<%=basePath%>vendors/bootstrap-daterangepicker/daterangepicker.js"></script>
	<!-- Chart.js -->
	<script src="<%=basePath%>vendors/Chart.js/dist/Chart.min.js"></script>

	<!-- Custom Theme Scripts -->
	<script src="<%=basePath%>build/js/custom.min.js"></script>
</body>
</html>